package com.example.controller;

import java.io.IOException;
import java.rmi.RemoteException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.service.impl.AutoCbsServerImpl;
import com.example.service.impl.AutoJobcArdPIServerImpl;

import net.sf.json.JSONObject;

@RestController
@Component
@RequestMapping("AutoJobcardPI")
public class AutoJobcardPIController {

	@Autowired
	public AutoJobcArdPIServerImpl AutoJobcArdServer;
	@Autowired
	public AutoCbsServerImpl AutoCbsServer;

	/**
	 * 自动生成与下发管线专业Jobcard
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("testPI")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	public String dataTransPI() throws IOException {
		 AutoJobcArdServer.auto_IssuedJobcardPI_Approve2(); //自动过审所有图纸
		AutoJobcArdServer.auto_GenerateJobcard_PI();// 自动生成 PI专业JOBCARD
		  AutoJobcArdServer.auto_synchro_UXMMT_PI();// 自动生成 PI专业JOBCARD 物料缺失追踪
		return "Success";

	}

	/**
	 * 自动生成预工作包管线专业
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("testPI2")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	public String auto_PreWorkPackagePI() throws IOException {
		AutoJobcArdServer.auto_PreWorkPackagePI();// 自动生成 PI专业预工作包
		return "Success";

	}

	
	
	
	/**
	 * 自动发送预工作包管线专业
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("testPI3")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	public String auto_SendWorkPackage() throws IOException {
		AutoJobcArdServer.auto_SendWorkPackage();// 自动发送预工作包管线专业
		return "Success";

	}

	/**
	 * 查找相关成功的预工作包 将其下发
	 * 
	 * @return
	 * @throws RemoteException 
	 * @throws IOException
	 */
	@RequestMapping("testPI4")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	public void auto_IssuedWorkPackageJobcardPI_Approve() throws RemoteException {
		AutoJobcArdServer.auto_IssuedWorkPackageJobcardPI_Approve();
	}

	/**
	 *  
	 * 为iso图施工单进行备料
	 * @throws IOException
	 */
    public void auto_IssuedJobcardPI() throws IOException {
    	AutoJobcArdServer.auto_IssuedJobcardPI();
    }
	
	/**
	 * 管线专业套料插件访问接口
	 * 
	 * @param param
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("testPI5")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	@SuppressWarnings("unchecked")
	public String dataTrans2(@RequestBody JSONObject param) throws IOException {

		AutoJobcArdServer.update_WorkPackagePI(param);
		 
		return "调用成功了~~~";

	}
	
	
	@RequestMapping("testPI10")
	@ResponseBody
	// @Scheduled(cron = "0 0/2 * * * ?")
	@SuppressWarnings("unchecked")
	public String dataTrans6() throws IOException {

		return "调用成功了~~~";

	}
	

}
